package org.niugang.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * 
 *
 * Copyright: Copyright (c) 2018 863263957@qq.com 
 *  密码加密解密工具类
 * 
 * @ClassName: BPwdEncoderUtils.java
 * @version: v1.0.0
 * @author: niugang
 * @date: 2018年11月20日 下午12:06:29
 */
public class BPwdEncoderUtils {

	private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();

	/**
	 * 用BCryptPasswordEncoder
	 * 
	 * @param password
	 * @return
	 */
	public static String BCryptPassword(String password) {
		return encoder.encode(password);
	}

	/**
	 *
	 * @param rawPassword     原始密码
	 * @param encodedPassword 加密后的密码
	 * @return
	 */
	public static boolean matches(CharSequence rawPassword, String encodedPassword) {
		return encoder.matches(rawPassword, encodedPassword);
	}

}
